package swu.cx.master_of_mental_arithmetic

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.SavedStateViewModelFactory
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.fragment.findNavController
import swu.cx.master_of_mental_arithmetic.databinding.FragmentWinBinding

class WinFragment : Fragment() {

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        //return inflater.inflate(R.layout.fragment_win, container, false)
        val viewModel = ViewModelProvider(requireActivity(),
            SavedStateViewModelFactory(requireActivity().application,requireActivity())
        ).get(MyViewModel::class.java)
        val binding = DataBindingUtil.inflate<FragmentWinBinding>(inflater,R.layout.fragment_win,container,false)
        binding.data = viewModel
        binding.lifecycleOwner = requireActivity()
        binding.button11.setOnClickListener {
            val action = WinFragmentDirections.actionWinFragmentToTitleFragment()
            findNavController().navigate(action)
        }
        return binding.root
    }

}